﻿package org.nickro.project.sound{
    import com.tobyfreeman.utils.*;
	import org.nickro.project.utils.
    public class SoundDef {
		//
        public var pCrossover:Number;
        public var pIsExternal:Boolean;
        public var pVolume:Number;
        public var pPan:Number;
        public var pFilename:String;
        public var pName:String;
        public var pIsMP3:Boolean;

        private static const DEFAULT_CROSSOVER:Number = 0;
        private static const EXTENSION_MP3:String = ".mp3";
        private static const DEFAULT_VOLUME:Number = 1;
        private static const DEFAULT_PAN:Number = 0;

        public function SoundDef(name:String, volume:Number = 1, pan:Number = 0, crossover:Number = 0){
            pName = name;
            pVolume = Math.max(0, Math.min(volume, 1));
            pPan = Math.max(-1, Math.min(pan, 1));
            pCrossover = Math.max(0, Math.min(crossover, 1));
            pIsMP3 = Strings.endsWith(pName, EXTENSION_MP3);
            pIsExternal = pIsMP3;
            if (pIsExternal){
                pFilename = name;
                if (pIsMP3){
                    pName = pName.substring(0, (pName.length - EXTENSION_MP3.length));
                };
            };
        }
        public function toString():String{
            return ((((("[object SoundDef name='" + pName) + "' external='") + pIsExternal) + "']"));
        }

    }
}